package com.mmall.concurrence.singleton;

import com.mmall.concurrence.annoations.NotRecommend;
import com.mmall.concurrence.annoations.ThreadSafe;

/**
 * 懒汉模式
 *
 *  性能太低
 *
 * @author yuelinbo
 * @date 2018/12/18 9:57
 **/
@ThreadSafe
@NotRecommend
public class SingletonExample1 {

    //私有构造函数
    private SingletonExample1(){

    }

    //静态私有单例对象
    private static SingletonExample1 instance = null;

    //静态的工厂方法
    public  static synchronized SingletonExample1 getInstance(){
        if(instance == null){
            instance = new SingletonExample1();
        }

        return instance;
    }
}
